package com.nhjf.dao.followThePainting.followThePaintingDetails;

import org.apache.commons.lang.StringUtils;
import org.hibernate.Criteria;
import org.hibernate.FetchMode;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import com.nhjf.dao.BaseDao;
import com.nhjf.model.followThePainting.followThePaintingDetails.FollowThePaintingDetails;
import com.nhjf.pojo.qo.followThePainting.followThePaintingDetailsQo.FollowThePaintingDetailsQo;

@Repository
public class FollowThePaintingDetailsDao extends BaseDao<FollowThePaintingDetails, FollowThePaintingDetailsQo>{

	@Override
	protected Criteria buildCriteria(Criteria criteria, FollowThePaintingDetailsQo qo) {
		// TODO Auto-generated method stub
		if(qo.getCreationTime()!=null) {
			criteria.add(Restrictions.eq("creationTime",qo.getCreationTime()));
		}
		if(StringUtils.isNotBlank(qo.getDetailPicture())) {
			criteria.add(Restrictions.eq("detailPicture",qo.getDetailPicture()));
		}
		if(qo.getFollowThePaintingId()!=null) {
			
			criteria.add(Restrictions.eq("followThePaintingId",qo.getFollowThePaintingId()));
		}
		if(StringUtils.isNotBlank(qo.getPictureDescription())) {
			criteria.add(Restrictions.eq("pictureDescription",qo.getPictureDescription()));
		}
		if(StringUtils.isNotBlank(qo.getPictureTitle())) {
			criteria.add(Restrictions.eq("pictureTitle",qo.getPictureTitle()));
		}
		criteria.addOrder(Order.asc("id"));
		return criteria;
	}

	@Override
	protected Class<FollowThePaintingDetails> getEntityClass() {
		// TODO Auto-generated method stub
		return FollowThePaintingDetails.class;
	}

}
